package com.itheima.mapper;

import com.github.pagehelper.Page;
import com.itheima.pojo.Clazz;
import com.itheima.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ClazzMapper {

    /**
     * 班级列表查询（分页查询）
     *
     * @param clazzQueryParam
     * @return
     */
    Page<Clazz> pageQuery(ClazzQueryParam clazzQueryParam);


    /**
     * 删除班级
     *
     * @param id
     */
    @Delete("delete from clazz where id = #{id}")
    void delete(Integer id);


    /**
     * 添加班级
     *
     * @param clazz
     */
    @Insert("insert into clazz(name,room,begin_date,end_date,master_id,subject,create_time,update_time) values (#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void insert(Clazz clazz);


    /**
     * 根据id查询班级
     *
     * @param id
     * @return
     */
    @Select("select * from clazz where id = #{id}")
    Clazz getByClazzId(Integer id);


    /**
     * 修改班级
     *
     * @param clazz
     */
    void update(Clazz clazz);


    /**
     * 查询所有班级
     *
     * @return
     */
    @Select("select * from clazz order by update_time desc ")
    List<Clazz> selectAll();
}
